import React from "react";
import Switch from "../../../Switch";
import type { FieldBaseType } from "../../type";

interface SwitchFieldProps {
  field: FieldBaseType<boolean>;
  onChange: (value: boolean) => void;
}

export default function SwitchField({ field, onChange }: SwitchFieldProps) {
  const { value, defaultValue, disabled } = field;

  return (
    <div className="switch-field">
      <Switch
        value={value ?? defaultValue}
        onChange={onChange}
        disabled={disabled}
      />
    </div>
  );
}
